package cn.tedu.coolshark01.user.controller;

import cn.tedu.coolshark01.base.response.JsonResult;
import cn.tedu.coolshark01.user.pojo.dto.ProductQuery;
import cn.tedu.coolshark01.user.pojo.dto.UserLoginParam;
import cn.tedu.coolshark01.user.pojo.vo.ProductVO;
import cn.tedu.coolshark01.user.pojo.vo.UserVO;
import cn.tedu.coolshark01.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
//@Slf4j用来标识当前类为日志类
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController{
    @Autowired
     UserService UserService;
    @PostMapping("login")
    public JsonResult login(@RequestBody UserLoginParam userLoginParam){
        log.debug("用户登录参数：{}", userLoginParam);
        //Ctrl去接口 Ctrl+Alt去实现类
        UserVO userVO = UserService.login(userLoginParam);
        return JsonResult.ok(userVO);
    }

    @GetMapping("select")
    public JsonResult selectproduct(ProductQuery productQuery){
        log.debug("用户查询参数：{}", productQuery);
        List<ProductVO> list = UserService.selectproduct(productQuery);
        return JsonResult.ok(list);
    };
}
